package cn.shyouchi.wuguanjia.android.ui.statistic.page;

import android.content.Intent;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.api.attendance.AttendanceApi;
import cn.shyouchi.wuguanjia.android.ui.statistic.RankItemColorAgent;
import cn.shyouchi.wuguanjia.android.ui.statistic.SignStatisticProfileActivity;

/**
 * Created by Eenie on 2016/12/13 at 18:21
 * Email: 472279981@qq.com
 * Des:
 */

public class MonthStatisticAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    RankItemColorAgent mRankItemColorAgent;


    String date;

    AttendanceApi mAttendanceApi;

    String projectId;

    public MonthStatisticAdapter(List<String> data, String projectId) {

        super(R.layout.item_year_statistic_layout, data);
        mRankItemColorAgent = new RankItemColorAgent();
        date = "";
        this.projectId = projectId;

    }

    @Override
    protected void convert(BaseViewHolder holder, final String date) {


        holder.setText(R.id.model_date, date);

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(mContext, SignStatisticProfileActivity.class);
                intent.putExtra("date", date);
                intent.putExtra("projectId", projectId);

                mContext.startActivity(intent);
            }
        });

//        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DisplayUtil.dip2px(mContext, 50), DisplayUtil.dip2px(mContext, 50));
//        holder.setText(R.id.tv_user_name, String.format("%s | %s", entity.getInfo().getName(), entity.getInfo().getPermissions()));
//        holder.setText(R.id.tv_user_day, String.format("出勤：%s天", entity.getInfo().getWork_number()));
//        holder.setText(R.id.tv_user_date, date);
//        LinearLayout layout = holder.getView(R.id.lin_rank_group);
//
//        if (mAttendanceApi == null) {
//            mAttendanceApi = new AttendanceApi(mContext);
//        }
//
//        layout.removeAllViews();
//
//
//        if (entity.getInfo().getService() != null) {
//            for (YearStatisticEntity.ResultMessageBean.UserBean.InfoBeanXX.ServiceBean s : entity.getInfo().getService()) {
//                View view = LayoutInflater.from(mContext).inflate(R.layout.layout_statistic_item, null);
//                view.setLayoutParams(lp);
//                view.setBackgroundColor(mRankItemColorAgent.getColorByRankName(s.getServicesname()));
//                TextView tvDes = (TextView) view.findViewById(R.id.tv_des_name);
//                TextView tvNum = (TextView) view.findViewById(R.id.tv_des_num);
//                tvDes.setText(s.getServicesname());
//
//                tvNum.setText(String.valueOf(s.getWork_day()));
//                layout.addView(view);
//            }
//        } else {
//            View view = LayoutInflater.from(mContext).inflate(R.layout.layout_statistic_item, null);
//            view.setLayoutParams(lp);
//            view.setBackgroundColor(mRankItemColorAgent.getColorByRankName("休息日"));
//            TextView tvDes = (TextView) view.findViewById(R.id.tv_des_name);
//            TextView tvNum = (TextView) view.findViewById(R.id.tv_des_num);
//            tvDes.setText("休息日");
//            Calendar calendar = Calendar.getInstance();
//            String[] fields = date.split("-");
//            calendar.set(Calendar.YEAR, Integer.parseInt(fields[0]));
//            calendar.set(Calendar.YEAR, Integer.parseInt(fields[0]) - 1);
//            tvNum.setText(String.valueOf(calendar.getMaximum(Calendar.DAY_OF_MONTH)));
//            layout.addView(view);
//        }
//
//
//        holder.itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                Intent intent = new Intent(mContext, StaffStatisticsActivity.class);
//                intent.putExtra("userid", entity);
//                intent.putExtra("date", date);
//                mContext.startActivity(intent);
//            }
//        });
    }


    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }
}
